# coding:utf-8
import requests
import json


class SendWrap:

    def __init__(self, addr):
        self.headers = {'content-type': "application/json",
                        'Authorization': 'APP appid = 4abf1a,token = 9480295ab2e2eddb8'}
        self.execute_point = [
            addr,
        ]

    @staticmethod
    def _buildBody(data):
        body = {"type": "text", "content": data, "tag_id": "20717"}
        return body

    def SendData(self, data):
        ret = None
        for i in self.execute_point:
            bodyd = self._buildBody(data)
            try:
                s = requests.session()
                s.keep_alive = False
                ret = requests.post(i, data=json.dumps(bodyd), headers=self.headers, timeout=(6.01, 6.01))
            except Exception as e:
                print('recv post exception:' + str(e))
            return ret

    if __name__ == "__main__":
        a = SendWrap()
        ad = {}
        ad["id"] = -1
        r = a.SendData(ad)
        print(r.text)
